﻿/** Code By Muzaffer Dede
*   Lexionlu Design Firm
*   2013 (C)
**/

$(document).ready(function () {


    /*Navigation dropdown last child bottom line remove*/
    $('.drop-left ul li:last-child').not(':has(ul)').css({ 'background': 'none' });

    /*Toggle boxes Show/Hide*/
    $('*').click(function (e) {
        if (e.originalEvent !== undefined) {
            toggleDiv($('.JS-member-login-btn'), $('.login-areas .login-box').eq(0), e);
            toggleDiv($('.JS-bussinese-login-btn'), $('.login-areas .login-box').eq(1), e);
            toggleDiv($('.JS-basket'), $('.shopping-cart-box'), e);
        }
    });


    $('.JS-add').click(function (e) {
        /* Add item to the cart then fire this function to show list and highlight the last added item */
        /* addProduct(); */

        /*!!!demo!!!!*/
        /*Add by Ajax*/
            var newItem = $('.list-item:first-child').clone();
            $('.slide-area').append(newItem);
        /*When Ajax complate call this function*/
            addProduct();
        /*!!!demo!!!!*/

    });

    /* Social network */
    $('.heart').hover(function () {
        $('.share-tools', this).stop(true, true).fadeIn(100);
    }, function () {
        $('.share-tools', this).stop(true, true).fadeOut(100);
    });

    /*Dropdown*/
    dropdown($('.JS-navigation'));

    /* Hover Up Description */
    $('.product-list .product-item').each(function () {
        hoverUp($(this));
    });

    /* check Device for pad slider */
    checkDevice();
    $('.home-list .list-item').each(function () {
        hoverUp($(this));
    });

    /* Demo lightbox */
    $('#id1').click(function () {
        lightbox($(".popup-content .member-lightbox").prop('outerHTML'));
    });
    $('#id2').click(function () {
        lightbox($(".popup-content .outlink").prop('outerHTML'));
    });
    $('#id3').click(function () {
        lightbox($(".popup-content .email").prop('outerHTML'));
    });
    $('#id4').click(function () {
        lightbox($(".popup-content .message-type1").prop('outerHTML'));
    });
    $('#id5').click(function () {
        lightbox($(".popup-content .message-type2").prop('outerHTML'));
    });
    $('#id6').click(function () {
        lightbox($(".popup-content .message-type3").prop('outerHTML'));
    });
    $('#id7').click(function () {
        lightbox($(".popup-content .message-type4").prop('outerHTML'));
    });
    $('#id8').click(function () {
        lightbox($(".popup-content .message-type5").prop('outerHTML'));
    });
    $('#id9').click(function () {
        lightbox($(".popup-content .message-type6").prop('outerHTML'));
    });
    $('#id10').click(function () {
        lightbox($(".popup-content .message-type7").prop('outerHTML'));
    });
    $('#id11').click(function () {
        lightbox($(".popup-content .credit-card").prop('outerHTML'));
    });

    /* Tabs */
    $('.JS-login-links a').live('mousedown', function () {
        lightTab($(this), $('.lightbox .tab-areas'));
    });

    $('.JS-tabs ul li a').click(function () {
        tab($(this), $('.tab-areas'));
        return false;
    });

    /* Sliders */
    $('.home-list .list-item').each(function () {
        slider($(this));
    });

    $('.JS-slider').each(function () {
        slider($(this));
    });

    shoppingSlider($('.shopping-cart-box'));

    textSlider($('.text-slider'));

    indexSlider($('.JS_indexSlider'));

    listSlider($('.JS_listSlide'));

    /* Select All */
    $('.select-all').toggle(
        function () {
            $(this).text("取消全選");
            $('.wish input[type="checkbox"]').prop('checked', true);
        },
        function () {
            $(this).text("全選");
            $('.wish input[type="checkbox"]').prop('checked', false);
        }
    );

    $('.list-acord').click(function () {
        acordion(this, $('.JS_talbe'));
    });

    $('.faq .titler').click(function () {
        acordion(this, $('.desc',$(this).parent()));
    });
    numpad($('.numpad'));
    $('.form table a .shower').click(function () {
        $('.target').show();
        return false;
    });
});

